package com.cdut.hwadeefsc.service.impl;

import com.cdut.hwadeefsc.entity.comments;
import com.cdut.hwadeefsc.mapper.commentsMapper;
import com.cdut.hwadeefsc.service.commentsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class commentsServiceImpl implements commentsService {

    @Autowired
    private commentsMapper commentsMapper;

    // 修改参数类型为Long（与实体类和Mapper保持一致）
    @Override
    public List<comments> getStudentComments(Long studentId) {
        return commentsMapper.findByStudentId(studentId);
    }

    // 修改参数类型为Long，方法名和参数名同步改为term（与Mapper保持一致）
    @Override
    public List<comments> getStudentCommentsBySemester(Long studentId, String term) {
        return commentsMapper.findByStudentIdAndTerm(studentId, term);
    }

    @Override
    public boolean addComment(comments comment) {
        return commentsMapper.insert(comment) > 0;
    }

    @Override
    public boolean updateComment(comments comment) {
        return commentsMapper.update(comment) > 0;
    }

    // 修改参数类型为Long（与实体类id类型一致）
    @Override
    public boolean deleteComment(Long commentId) {
        return commentsMapper.delete(commentId) > 0;
    }
}




